<template>
	<view>
		<view style="height: 100rpx;"></view>
		<view class="foot">
			<view class="page-footer" id="target" style="background-color:#fff">
				<view class="foot-item" v-for="(item,index) in menu" :key="index"
					@click="goRouter(item)">
					<!-- @click="goRouter(item)" v-if="index!=2"> -->
					<block >
						<block v-if="item.link == activeRouter">
							<image :src="item.imgList[1]"></image>
							<view class="txt" style="color: rgb(241,194,89);">{{item.name}}
							</view>
						</block>
						<block v-else>
							<image :src="item.imgList[0]"></image>
							<view class="txt" style="color: rgb(90,90,90);">{{item.name}}</view>
						</block>
					</block>
				</view>
			</view>
		</view>
	</view>
</template>

<script>

	export default{
		props: {
			activeRouter: {
				type: String,
				default: '',
			}
		},
		data(){
			return {
				menu:[],
				menuList:{
					merchant:[
						{
							name:"首页",
							link:"/pages/tabBar/merchant/index",
							imgList:[
								"../static/tabIcon/merchant-1-001.png",
								"../static/tabIcon/merchant-1-002.png"
							]
						},
						{
							name:"订单",
							link:"/pages/tabBar/merchant/order",
							imgList:[
								"../static/tabIcon/merchant-2-001.png",
								"../static/tabIcon/merchant-2-002.png"
							]
						},
						{
							name:"我的",
							link:"/pages/tabBar/merchant/mine",
							imgList:[
								"../static/tabIcon/merchant-3-001.png",
								"../static/tabIcon/merchant-3-002.png"
							]
						}
					],
					commercialAffairs:[
						{
							name:"目标管理",
							link:"/pages/tabBar/manager",
							imgList:[
								"merchant-1-001.png",
								"merchant-1-002.png"
							]
						},
						{
							name:"店铺管理",
							link:"/pages/tabBar/manager",
							imgList:[
								"merchant-2-001.png",
								"merchant-2-002.png"
							]
						},
						{
							name:"业绩管理",
							link:"/pages/tabBar/manager",
							imgList:[
								"merchant-3-001.png",
								"merchant-3-002.png"
							]
						},
						{
							name:"我的",
							link:"/pages/tabBar/manager",
							imgList:[
								"merchant-3-001.png",
								"merchant-3-002.png"
							]
						}
					]
				}
			}
		},
		mounted() {
			uni.hideTabBar();
			this.menu = this.menuList.merchant;
		},
		methods:{	
			goRouter(item) {
				var pages = getCurrentPages();
				var page = (pages[pages.length - 1]).$page.fullPath;
				if (item.link == page) return
				// console.log(1);
				this.$Router.replace({
					path: item.link
				})
				// uni.switchTab({
				// 	url: item.link,
				// 	fail(err) {
				// 		uni.redirectTo({
				// 			url: item.link
				// 		})
				// 	}
				// })
			},
		}
	}
	
</script>

<style lang="scss" scoped>
	.page-footer {
		position: fixed;
		bottom: 0;
		z-index: 999999;
		display: flex;
		align-items: center;
		justify-content: space-around;
		width: 100%;
		height: calc(98rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
		height: calc(98rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
		box-sizing: border-box;
		border-top: 1px solid #F3F3F3;
		background-color: #fff;
		box-shadow: 0px 0px 17rpx 1rpx rgba(206, 206, 206, 0.32);
		padding-bottom: constant(safe-area-inset-bottom); ///兼容 IOS<11.2/
		padding-bottom: env(safe-area-inset-bottom); ///兼容 IOS>11.2/
		&.filter{
			filter: blur(2rpx);
		}
		.foot-item {
			display: flex;
			width: max-content;
			align-items: center;
			justify-content: center;
			flex-direction: column;
			position: relative;
			.count-num {
				position: absolute;
				display: flex;
				justify-content: center;
				align-items: center;
				width: 40rpx;
				height: 40rpx;
				top: 0rpx;
				right: -15rpx;
				color: #fff;
				font-size: 20rpx;
				background-color: #FD502F;
				border-radius: 50%;
				padding: 4rpx;
			}
		}
		.foot-item image {
			height: 50rpx;
			width: 50rpx;
			text-align: center;
			margin: 0 auto;
		}
		.foot-item .txt {
			font-size: 24rpx;
		}
	}
</style>
